from django.db import models
from django.conf import settings
from django.contrib.auth.models import User
import datetime
class SyncLog(models.Model):
    sf_object = models.CharField(max_length=100)
    status = models.IntegerField(default=0)
    sf_query=models.TextField(null=True)
    rec_count = models.IntegerField(default=0)
    errors = models.IntegerField(default=0)
    added = models.IntegerField(default=0)
    updated = models.IntegerField(default=0)
    local = models.BooleanField(default=False)
    manual = models.BooleanField(default=False)
    user = models.ForeignKey(User,null=True,blank=True)
    utype = models.CharField(max_length=100,default='Content')
    error_code = models.CharField(max_length=255)
    error_text = models.TextField(max_length=1000)
    action = models.CharField(max_length=100,null=True,blank=True)
    lid = models.IntegerField(null=True,blank=True)
    sf_id = models.TextField(max_length=18,null=True,blank=True)
    #user = models.ForeignKey(User)
    started = models.DateTimeField(null=True)
    ended = models.DateTimeField(null=True)
    def get_utc_time(self):
        return datetime.datetime.utcnow()
    class Meta:
        db_table ="sync_sync_log"
        ordering = ["-started"]
        app_label = 'sync'